/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package NEHE.JOGL.Port;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
  
public class JOGLTemplateMain extends JFrame {
   private static final int WINDOW_WIDTH = 640;
   private static final int WINDOW_HEIGHT = 480;
   private static final String WINDOW_TITLE = "JOGL Program Template";
  
   // Constructor
   public JOGLTemplateMain() {
      final JOGLTemplate joglMain = new JOGLTemplate();
      this.setContentPane(joglMain);
      this.addWindowListener(new WindowAdapter() {
         @Override 
         public void windowClosing(WindowEvent e) {
            // Use a dedicate thread to run the stop() to ensure that the
            // animator stops before program exits.
            new Thread() {
               @Override 
               public void run() {
                  joglMain.animator.stop(); // stop the animator loop
                  System.exit(0);
               }
            }.start();
         }
      });
      this.setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
      this.setTitle(WINDOW_TITLE);
      this.setVisible(true);
      joglMain.animator.start(); // start the animation loop
   }
   
   // main method
   public static void main(String[] args) {
      new JOGLTemplateMain();
   }
}
